<!DOCTYPE html>
<html lang="zh-cn">
<head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <title>h5支付</title>
</head>

<body>
<div class="login-container animated fadeInDown" style="text-align: center">
          请输入金额:<input type="text"  id="totalPriceReal"><br/>
        <br/>
        <input type="button" value="去支付" οnclick="submintPay()">
</div>
<script>
    function submintPay(){
        alert(11)
        var totalPriceReal=$("#totalPriceReal").val();//商品金额
        var reg = /(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/;
        if (reg.test(totalPriceReal)) {
            var orderIofn={
                "totalPriceReal":totalPriceReal
            };
            $.ajax({
                url:"http://localhost:8888/wxApi/huahao/wxPay/wxPay",
                data:orderIofn,
                type: "POST",
                async: false,
                success:function(data){
                    if(data.header.retCode=='000000'){
                        // alert(JSON.stringify(data));
                        //支付唤起微信连接
                        var mweb_url=data.body.mweb_url;
                        //支付完成连接
                        var mweb_complete_url="http://ftrain.yladc.com/fsp/wechatpay/gotoPayCompletion";
                        self.location.href=mweb_url+"&redirect_url="+mweb_complete_url;
                    }else{
                        //alert(JSON.stringify(data));
                    }
                },
                error:function(){
                    layer.close(load_index);
                    layer.msg("删除失败");
                }
            });
        }else{
            alert("请输入合法金额");
        };
    }
</script>
</body>
</html>